<template>
  <s-layout tabbar="/pages/index/user" navbar="my" :navbar-left-icon="false" :title="getLangValue('我的')">
    <!-- <view class="page-name">我的</view> -->
    <su-status-bar />
    <view class="user-info ss-flex ss-col-center">
      <view class="flex align-center">
        <image class="avatar" src="../../static/default_avatar.png" />
        <view class="user-name">
      <!--    <view>{{sheep.$store('user').userInfo.user.nickname}}</view>
          <view>用户当前角色{{sheep.$store('user')?.userInfo?.roles.join(',')}}</view> -->
        </view>
      </view>
      <!-- <view>
        <uni-icons type="compose" color="#fff" size="30" @click="to('/pages/user/info')" />
      </view> -->
    </view>

    <view class="list">
      <uni-list :border="false">
        <!-- <uni-list-item class="ss-p-y-14" :border="false" title="切换角色" show-arrow thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" thumb-size="base" /> -->
        <uni-list-item
          class="ss-p-y-14"
          :border="false"
          :title="getLangValue('版本号')"
         thumb="../../static/icon/versions.png"
         thumb-size="sm"
          :right-text="'v'+version"
        />
        <!-- <uni-list-item class="ss-p-y-14" :border="false" title="修改密码" show-arrow thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png" thumb-size="base" /> -->
        <uni-list-item
          class="ss-p-y-14"
          :border="false"
          :title="getLangValue('退出登录')"
          show-arrow
					clickable
					thumb="../../static/icon/out.png"
          thumb-size="sm"
          @click="loginOut"
        />
      </uni-list>
    </view>
  </s-layout>
</template>

<script setup>
	import {
	  version
	} from '@/sheep/config'
import { computed, ref } from 'vue'
import { onLoad, onShow, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'
import sheep from '@/sheep'
	import useLang from '@/sheep/hooks/useLang.js'
	const {
		getLangValue
	} = useLang()
	
// 隐藏原生tabBar
uni.hideTabBar()

onLoad((options) => {})

const to = (url) => {
  sheep.$router.go(url)
}

const loginOut = async () => {
	try {
		await sheep.$helper.confirmModal({
			content: getLangValue('确认提出登录？')
		})
	} catch {
		return
	}
  sheep.$store('user').loginOut()
}

// 下拉刷新
onPullDownRefresh(() => {
  // sheep.$store('user').updateUserData()
  setTimeout(function() {
    uni.stopPullDownRefresh()
  }, 800)
})

onShow(() => {
  sheep.$store('user').updateUserData()
})

onPageScroll(() => {})
</script>

<style lang="scss" scoped>
.page-name {
	text-align: center;
			background: var(--ui-BG-Main);
	color: #fff;
	font-size: 40rpx;
}
.user-info {
	background: var(--ui-BG-Main);
	height: 360rpx;
	padding: 0 40rpx;

	.avatar {
		margin-right: 20rpx;
		background-color: #fff;
		border-radius: 50%;
		width: 120rpx;
		height: 120rpx;
	}
	.user-name {
		color: #fff;

		:first-child {
			font-size: 50rpx;
		}
		:last-child {
			margin-top: 10rpx;
			font-size: 26rpx;
		}
	}
}
.list {
	position: absolute;
	margin-top: -20rpx;
	border-radius: 30rpx 30rpx 0 0;
	padding-top: 20rpx;
	background-color: #fff;
	bottom: 0;
	top: 350rpx;
	left: 0;
	right: 0;
}
</style>
